﻿using System;
using System.Collections.Generic;
using VideoSeller.Business.Data.Entities;

namespace VideoSeller.Web.Models
{
	public class StatisticOnlinePeriodViewModel : BaseViewModel
	{
		public IEnumerable<StatisticOnlineItem> Items { get; set; }

		public string StartDate { get; set; }

		public string StartTime { get; set; }

		public string EndDate { get; set; }

		public string EndTime { get; set; }

		public DateTime StartDateTime
		{
			get
			{
				if (!string.IsNullOrEmpty(StartDate) && !string.IsNullOrEmpty(StartTime))
				{
					return DateTime.Parse(string.Format("{0} {1}", StartDate, StartTime));
				}

				if (!string.IsNullOrEmpty(StartDate))
				{
					return DateTime.Parse(StartDate);
				}

				return DateTime.MinValue;
			}
		}

		public DateTime EndDateTime
		{
			get
			{
				if (!string.IsNullOrEmpty(EndDate) && !string.IsNullOrEmpty(EndTime))
				{
					return DateTime.Parse(string.Format("{0} {1}", EndDate, EndTime));
				}

				if (!string.IsNullOrEmpty(EndDate))
				{
					return DateTime.Parse(EndDate);
				}

				return DateTime.MinValue;
			}
		}
	}
}